This sheet shows a Custom Button with a Control Script. When you click on the button, the script uses Draw commands to draw rectangles, ovals, pies and polygons with different line sizes, colors and patterns. To view the script, select the Custom Button with the Object Tool and go to the Script Menu, under Control Script. For more information about the Draw commands, please refer to the Reference Guide on page 165.
Chicago
draw_box
draw_oval
draw_piez
draw_polygon
draw_spline
{This script demonstrates the use of the Draw commands. The variables (x0,y0,x1,y1) are the
coordinates for the objects that will be drawn.
The function rand() is used to produce a random number between 0 and 1 for the coordinates.
The function uniform() is also used to produce a random number between 0 and the number specified.
The Frame command (i.e. Frame Rectangle) determines the current line style for the object.
The Fill command (i.e. Fill Rectangle determines the current brush color. The Paint command
(i.e. Paint Rectangle) determines both the line style and the brush color.
More information about the draw commands can be found in the Wingz Reference Guide, on page 165.}
repaint object 1
function draw_box()
define x0, y0, x1, y1, t
x0 = rand()
y0 = rand()
x1 = rand()
y1 = rand()
if x0 > x1
t = x0
x0 = x1
x1 = t
end if
if y0 > y1
t = y0
y0 = y1
y1 = t
end if
case round(uniform(5),0)
when 0
frame rectangle (x0, y0) (x1, y1)
when 1
fill rectangle (x0, y0) (x1, y1)
when 2
paint rectangle (x0, y0) (x1, y1)
when 3
frame round rectangle (x0, y0) (x1, y1)
when 4
fill round rectangle (x0, y0) (x1, y1)
when 5
paint round rectangle (x0, y0) (x1, y1)
end case
end function
function draw_oval()
define x0, y0, x1, y1, t
x0 = rand()
y0 = rand()
x1 = rand()
y1 = rand()
if x0 > x1
t = x0
x0 = x1
x1 = t
end if
if y0 > y1
t = y0
y0 = y1
y1 = t
end if
case round(uniform(2),0)
when 0
frame oval (x0, y0) (x1, y1)
when 1
fill oval (x0, y0) (x1, y1)
when 2
paint oval (x0, y0) (x1, y1)
end case
end function
function draw_pie()
define x0, y0, x1, y1, t
x0 = rand()
y0 = rand()
x1 = rand()
y1 = rand()
if x0 > x1
t = x0
x0 = x1
x1 = t
end if
if y0 > y1
t = y0
y0 = y1
y1 = t
end if
case round(uniform(2),0)
when 0
frame pie (x0, y0) (x1, y1)
uniform(360) for uniform(360)
when 1
fill pie (x0, y0) (x1, y1)
uniform(360) for uniform(360)
when 2
paint pie (x0, y0) (x1, y1)
uniform(360) for uniform(360)
end case
end function
function draw_polygon()
define x0, y0, i
x0 = rand()
y0 = rand()
open polygon
move (x0, y0)
for i = 1 to 5
draw (rand(), rand())
end for
draw (x0, y0)
close polygon
case round(uniform(2),0)
when 0
frame polygon
when 1
fill polygon
when 2
paint polygon
end case
kill polygon
end function
function draw_spline()
define x0, y0, x1, y1, x2, y2, i
x0 = rand()
y0 = rand()
x1 = rand()
y1 = rand()
x2 = rand()
y2 = rand()
open polygon
load spline (x0, y0)
load spline (x1, y1)
load spline (x2, y2)
for i = 1 to 5
draw spline (rand(), rand())
end for
draw spline (x0, y0)
draw spline (x1, y1)
draw spline (x2, y2)
close polygon
case round(uniform(2),0)
when 0
frame polygon
when 1
fill polygon
when 2
paint polygon
end case
kill polygon
end function
on repaint
define i
for i = 1 to 5
fill pattern uniform(38)
fill fg rgb(uniform(255), uniform(255), uniform(255))
fill bg rgb(uniform(255), uniform(255), uniform(255))
line width uniform(10) points
line pattern uniform(38)
line fg rgb(uniform(255), uniform(255), uniform(255))
line bg rgb(uniform(255), uniform(255), uniform(255))
case i
when 1
call draw_box()
when 2
call draw_oval()
when 3
call draw_pie()
when 4
call draw_polygon()
when 5
call draw_spline()
end case
end for
end repaint
Chicago
Chicago
qg labels. Uses the ImageWriter'
drawings sheetd
WZSSWNGZ
WZSSWNGZ
authoritative information available on FileMake
<Example of using a button in Wingz to produce line drawings.
<Example of using a button in Wingz to produce line drawings.gs.